package signal

import (
	"core/component/logger"
	"os"
	"os/signal"
	"syscall"
)

var (
	signalChan = make(chan os.Signal, 0)
)

func WatchSignal() {
	signal.Notify(signalChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT, syscall.SIGTERM, syscall.SIGPIPE)
	for sig := range signalChan {
		switch sig {
		case syscall.SIGHUP:
			//svc.Impl.Reload()
		case syscall.SIGPIPE:
		default:
			logger.Infof("[service] 进程收到信号准备退出...")
			close(signalChan)
			break
		}
	}
}
